(*
 * This file is part of Asphyre Framework, also known as Platform eXtended Library (PXL).
 * Copyright (c) 2015 - 2017 Yuriy Kotsarenko. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations under the License.
 *)

const
  SystemFont8x8: array[0..2047] of Byte = (
    $00, $7E, $7E, $36, $08, $1C, $08, $00, $FF, $00, $FF, $F0, $3C, $FC, $FE, $99, $00, $81, $FF, $7F, $1C, $3E, $08,
    $00, $FF, $3C, $C3, $E0, $66, $CC, $C6, $5A, $00, $A5, $DB, $7F, $3E, $1C, $1C, $18, $E7, $66, $99, $F0, $66, $FC,
    $FE, $3C, $00, $81, $FF, $7F, $7F, $7F, $3E, $3C, $C3, $42, $BD, $BE, $66, $0C, $C6, $E7, $00, $BD, $C3, $3E, $3E,
    $7F, $7F, $3C, $C3, $42, $BD, $33, $3C, $0C, $C6, $E7, $00, $99, $E7, $1C, $1C, $6B, $3E, $18, $E7, $66, $99, $33,
    $18, $0E, $E6, $3C, $00, $81, $FF, $08, $08, $08, $08, $00, $FF, $3C, $C3, $33, $7E, $0F, $67, $5A, $00, $7E, $7E,
    $00, $00, $1C, $1C, $00, $FF, $00, $FF, $1E, $18, $07, $03, $99, $01, $40, $18, $66, $FE, $7E, $00, $18, $18, $18,
    $00, $00, $00, $00, $00, $00, $07, $70, $3C, $66, $DB, $C3, $00, $3C, $3C, $18, $18, $0C, $00, $24, $18, $FF, $1F,
    $7C, $7E, $66, $DB, $1E, $00, $7E, $7E, $18, $30, $06, $03, $66, $3C, $FF, $7F, $7F, $18, $66, $DE, $33, $00, $18,
    $18, $18, $7F, $7F, $03, $FF, $7E, $7E, $1F, $7C, $18, $66, $D8, $33, $7E, $7E, $18, $7E, $30, $06, $03, $66, $FF,
    $3C, $07, $70, $7E, $00, $D8, $1E, $7E, $3C, $18, $3C, $18, $0C, $7F, $24, $FF, $18, $01, $40, $3C, $66, $D8, $31,
    $7E, $18, $18, $18, $00, $00, $00, $00, $00, $00, $00, $00, $18, $00, $00, $1F, $00, $FF, $00, $00, $00, $00, $00,
    $00, $00, $00, $00, $0C, $36, $36, $0C, $00, $1C, $06, $18, $06, $00, $00, $00, $00, $00, $60, $00, $1E, $36, $36,
    $3E, $63, $36, $06, $0C, $0C, $66, $0C, $00, $00, $00, $30, $00, $1E, $36, $7F, $03, $33, $1C, $03, $06, $18, $3C,
    $0C, $00, $00, $00, $18, $00, $0C, $00, $36, $1E, $18, $6E, $00, $06, $18, $FF, $3F, $00, $3F, $00, $0C, $00, $0C,
    $00, $7F, $30, $0C, $3B, $00, $06, $18, $3C, $0C, $00, $00, $00, $06, $00, $00, $00, $36, $1F, $66, $33, $00, $0C,
    $0C, $66, $0C, $0E, $00, $0C, $03, $00, $0C, $00, $36, $0C, $63, $6E, $00, $18, $06, $00, $00, $0C, $00, $0C, $01,
    $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $06, $00, $00, $00, $1E, $0C, $1E, $1E, $38, $3F, $1C,
    $3F, $1E, $1E, $00, $00, $18, $00, $06, $1E, $33, $0F, $33, $33, $3C, $03, $06, $33, $33, $33, $00, $00, $0C, $00,
    $0C, $33, $3B, $0C, $30, $30, $36, $1F, $03, $30, $33, $33, $0C, $0C, $06, $3F, $18, $30, $3F, $0C, $1C, $1C, $33,
    $30, $1F, $18, $1E, $3E, $0C, $0C, $03, $00, $30, $18, $37, $0C, $06, $30, $7F, $30, $33, $0C, $33, $30, $00, $00,
    $06, $3F, $18, $0C, $33, $0C, $33, $33, $30, $33, $33, $06, $33, $18, $0C, $0E, $0C, $00, $0C, $00, $1E, $3F, $3F,
    $1E, $30, $1E, $1E, $06, $1E, $0E, $0C, $0C, $18, $00, $06, $0C, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
    $00, $06, $00, $00, $00, $00, $3E, $0C, $3F, $3C, $1F, $7F, $7F, $3C, $33, $1E, $78, $67, $0F, $63, $63, $1C, $63,
    $1E, $66, $66, $36, $46, $46, $66, $33, $0C, $30, $66, $06, $77, $67, $36, $7B, $33, $66, $03, $66, $16, $16, $03,
    $33, $0C, $30, $36, $06, $7F, $6F, $63, $7B, $33, $3E, $03, $66, $1E, $1E, $03, $3F, $0C, $30, $1E, $06, $6B, $7B,
    $63, $7B, $3F, $66, $03, $66, $16, $16, $73, $33, $0C, $33, $36, $46, $63, $73, $63, $03, $33, $66, $66, $36, $46,
    $06, $66, $33, $0C, $33, $66, $66, $63, $63, $36, $1E, $33, $3F, $3C, $1F, $7F, $0F, $7C, $33, $1E, $1E, $67, $7F,
    $63, $63, $1C, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $3F, $1E, $3F, $1E,
    $3F, $33, $33, $63, $63, $33, $7F, $1E, $03, $1E, $08, $00, $66, $33, $66, $33, $2D, $33, $33, $63, $63, $33, $33,
    $06, $06, $18, $1C, $00, $66, $33, $66, $07, $0C, $33, $33, $63, $36, $33, $19, $06, $0C, $18, $36, $00, $3E, $33,
    $3E, $1C, $0C, $33, $33, $6B, $1C, $1E, $0C, $06, $18, $18, $63, $00, $06, $3B, $1E, $38, $0C, $33, $33, $7F, $36,
    $0C, $46, $06, $30, $18, $00, $00, $06, $1E, $36, $33, $0C, $33, $1E, $77, $63, $0C, $63, $06, $60, $18, $00, $00,
    $0F, $38, $67, $1E, $1E, $3F, $0C, $63, $63, $1E, $7F, $1E, $40, $1E, $00, $00, $00, $00, $00, $00, $00, $00, $00,
    $00, $00, $00, $00, $00, $00, $00, $00, $FF, $0C, $00, $07, $00, $38, $00, $1C, $00, $07, $0C, $18, $07, $0E, $00,
    $00, $00, $0C, $00, $06, $00, $30, $00, $36, $00, $06, $00, $00, $06, $0C, $00, $00, $00, $18, $1E, $3E, $1E, $30,
    $1E, $06, $6E, $36, $0E, $1E, $66, $0C, $37, $1F, $1E, $00, $30, $66, $33, $3E, $33, $0F, $33, $6E, $0C, $18, $36,
    $0C, $7F, $33, $33, $00, $3E, $66, $03, $33, $3F, $06, $33, $66, $0C, $18, $1E, $0C, $6B, $33, $33, $00, $33, $66,
    $33, $33, $03, $06, $3E, $66, $0C, $18, $36, $0C, $63, $33, $33, $00, $6E, $3D, $1E, $6E, $1E, $0F, $30, $67, $1E,
    $1B, $67, $1E, $63, $33, $1E, $00, $00, $00, $00, $00, $00, $00, $1F, $00, $00, $0E, $00, $00, $00, $00, $00, $00,
    $00, $00, $00, $08, $00, $00, $00, $00, $00, $00, $38, $18, $07, $6E, $08, $00, $00, $00, $00, $0C, $00, $00, $00,
    $00, $00, $00, $0C, $18, $0C, $3B, $1C, $3B, $6E, $1B, $3E, $3E, $33, $33, $63, $63, $33, $3F, $0C, $18, $0C, $00,
    $36, $66, $33, $36, $03, $0C, $33, $33, $63, $36, $33, $19, $07, $00, $38, $00, $63, $66, $33, $36, $1E, $0C, $33,
    $33, $6B, $1C, $33, $0C, $0C, $18, $0C, $00, $63, $3E, $3E, $06, $30, $2C, $33, $1E, $7F, $36, $3E, $26, $0C, $18,
    $0C, $00, $63, $06, $30, $0F, $1F, $18, $6E, $0C, $36, $63, $30, $3F, $38, $18, $07, $00, $7F, $0F, $78, $00, $00,
    $00, $00, $00, $00, $00, $1F, $00, $00, $00, $00, $00, $00, $1E, $00, $38, $7E, $33, $07, $0C, $00, $7E, $33, $07,
    $33, $3E, $07, $33, $0C, $33, $33, $00, $C3, $00, $00, $0C, $00, $C3, $00, $00, $00, $63, $00, $0C, $0C, $03, $00,
    $1E, $3C, $1E, $1E, $1E, $3E, $3C, $1E, $1E, $0E, $1C, $0E, $1E, $00, $33, $33, $33, $60, $30, $30, $30, $03, $66,
    $33, $33, $0C, $18, $0C, $33, $1E, $1E, $33, $3F, $7C, $3E, $3E, $3E, $03, $7E, $3F, $3F, $0C, $18, $0C, $33, $33,
    $18, $33, $03, $66, $33, $33, $33, $3E, $06, $03, $03, $0C, $18, $0C, $3F, $3F, $30, $7E, $1E, $FC, $7E, $7E, $7E,
    $60, $3C, $1E, $1E, $1E, $3C, $1E, $33, $33, $1E, $00, $00, $00, $00, $00, $00, $3C, $00, $00, $00, $00, $00, $00,
    $00, $00, $38, $00, $7C, $1E, $00, $00, $1E, $00, $00, $63, $33, $18, $1C, $33, $0F, $70, $00, $00, $36, $33, $33,
    $07, $33, $07, $33, $1C, $00, $18, $36, $33, $1B, $D8, $3F, $FE, $33, $00, $00, $00, $00, $00, $00, $3E, $33, $7E,
    $26, $1E, $1B, $18, $06, $30, $7F, $1E, $1E, $1E, $33, $33, $33, $63, $33, $03, $0F, $3F, $2F, $7E, $1E, $FE, $33,
    $33, $33, $33, $33, $33, $33, $63, $33, $03, $06, $0C, $33, $18, $06, $33, $33, $33, $33, $33, $33, $33, $3F, $3E,
    $33, $7E, $67, $3F, $7B, $18, $3F, $FE, $73, $1E, $1E, $1E, $7E, $7E, $30, $1C, $1E, $18, $3F, $0C, $33, $1B, $00,
    $00, $00, $00, $00, $00, $00, $00, $1F, $00, $00, $18, $00, $00, $70, $0E, $38, $1C, $00, $00, $00, $3F, $3C, $3C,
    $0C, $00, $00, $63, $63, $00, $00, $00, $00, $00, $38, $38, $1F, $00, $36, $66, $00, $00, $00, $33, $33, $18, $CC,
    $33, $1E, $0E, $00, $00, $00, $33, $36, $66, $0C, $00, $00, $1B, $1B, $00, $66, $66, $30, $0C, $1E, $33, $1F, $37,
    $7C, $3C, $06, $3F, $3F, $7C, $CF, $18, $33, $CC, $3E, $0C, $33, $33, $33, $3F, $00, $00, $03, $03, $30, $C6, $E6,
    $18, $66, $66, $33, $0C, $33, $33, $33, $3B, $7E, $7E, $33, $03, $30, $73, $F3, $3C, $CC, $33, $7E, $1E, $1E, $7E,
    $33, $33, $00, $00, $1E, $00, $00, $19, $F9, $3C, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
    $F8, $C0, $18, $00, $00, $44, $AA, $3B, $18, $18, $18, $6C, $00, $00, $6C, $6C, $00, $6C, $6C, $18, $00, $11, $55,
    $6E, $18, $18, $18, $6C, $00, $00, $6C, $6C, $00, $6C, $6C, $18, $00, $44, $AA, $3B, $18, $18, $1F, $6C, $00, $1F,
    $6F, $6C, $7F, $6F, $6C, $1F, $00, $11, $55, $6E, $18, $18, $18, $6C, $00, $18, $60, $6C, $60, $60, $6C, $18, $00,
    $44, $AA, $3B, $18, $1F, $1F, $6F, $7F, $1F, $6F, $6C, $6F, $7F, $7F, $1F, $1F, $11, $55, $6E, $18, $18, $18, $6C,
    $6C, $18, $6C, $6C, $6C, $00, $00, $00, $18, $44, $AA, $3B, $18, $18, $18, $6C, $6C, $18, $6C, $6C, $6C, $00, $00,
    $00, $18, $11, $55, $6E, $18, $18, $18, $6C, $6C, $18, $6C, $6C, $6C, $00, $00, $00, $18, $18, $18, $00, $18, $00,
    $18, $18, $6C, $6C, $00, $6C, $00, $6C, $00, $6C, $18, $18, $18, $00, $18, $00, $18, $18, $6C, $6C, $00, $6C, $00,
    $6C, $00, $6C, $18, $18, $18, $00, $18, $00, $18, $F8, $6C, $EC, $FC, $EF, $FF, $EC, $FF, $EF, $FF, $18, $18, $00,
    $18, $00, $18, $18, $6C, $0C, $0C, $00, $00, $0C, $00, $00, $00, $F8, $FF, $FF, $F8, $FF, $FF, $F8, $EC, $FC, $EC,
    $FF, $EF, $EC, $FF, $EF, $FF, $00, $00, $18, $18, $00, $18, $18, $6C, $00, $6C, $00, $6C, $6C, $00, $6C, $00, $00,
    $00, $18, $18, $00, $18, $18, $6C, $00, $6C, $00, $6C, $6C, $00, $6C, $00, $00, $00, $18, $18, $00, $18, $18, $6C,
    $00, $6C, $00, $6C, $6C, $00, $6C, $00, $6C, $00, $00, $6C, $18, $00, $00, $6C, $18, $18, $00, $FF, $00, $0F, $F0,
    $FF, $6C, $00, $00, $6C, $18, $00, $00, $6C, $18, $18, $00, $FF, $00, $0F, $F0, $FF, $6C, $FF, $00, $6C, $F8, $F8,
    $00, $6C, $FF, $18, $00, $FF, $00, $0F, $F0, $FF, $6C, $00, $00, $6C, $18, $18, $00, $6C, $00, $18, $00, $FF, $00,
    $0F, $F0, $FF, $FF, $FF, $FF, $FC, $F8, $F8, $FC, $EF, $FF, $1F, $F8, $FF, $FF, $0F, $F0, $00, $00, $18, $6C, $00,
    $00, $18, $6C, $6C, $18, $00, $18, $FF, $FF, $0F, $F0, $00, $00, $18, $6C, $00, $00, $18, $6C, $6C, $18, $00, $18,
    $FF, $FF, $0F, $F0, $00, $00, $18, $6C, $00, $00, $18, $6C, $6C, $18, $00, $18, $FF, $FF, $0F, $F0, $00, $00, $00,
    $00, $00, $7F, $00, $00, $00, $3F, $1C, $1C, $38, $00, $60, $3C, $1E, $00, $1E, $7F, $7F, $66, $00, $66, $6E, $0C,
    $36, $36, $0C, $00, $30, $06, $33, $6E, $33, $63, $36, $0C, $7E, $66, $3B, $1E, $63, $63, $18, $7E, $7E, $03, $33,
    $3B, $1F, $03, $36, $18, $33, $66, $18, $33, $7F, $63, $3E, $DB, $DB, $3F, $33, $13, $33, $03, $36, $0C, $33, $66,
    $18, $33, $63, $36, $33, $DB, $DB, $03, $33, $3B, $1F, $03, $36, $66, $33, $3E, $18, $1E, $36, $36, $33, $7E, $7E,
    $06, $33, $6E, $03, $03, $36, $7F, $1E, $06, $18, $0C, $1C, $77, $1E, $00, $06, $3C, $33, $00, $03, $00, $00, $00,
    $00, $03, $00, $3F, $00, $00, $00, $00, $03, $00, $00, $00, $0C, $06, $18, $70, $18, $0C, $00, $1C, $00, $00, $F0,
    $1E, $1E, $00, $00, $3F, $0C, $0C, $0C, $D8, $18, $0C, $4E, $36, $00, $00, $30, $36, $30, $00, $00, $00, $3F, $18,
    $06, $D8, $18, $00, $39, $36, $00, $00, $30, $36, $1C, $3C, $00, $3F, $0C, $0C, $0C, $18, $18, $3F, $00, $1C, $18,
    $00, $30, $36, $06, $3C, $00, $00, $0C, $06, $18, $18, $18, $00, $4E, $00, $18, $18, $37, $36, $3E, $3C, $00, $3F,
    $00, $00, $00, $18, $1B, $0C, $39, $00, $00, $00, $36, $00, $00, $3C, $00, $00, $3F, $3F, $3F, $18, $1B, $0C, $00,
    $00, $00, $00, $3C, $00, $00, $00, $00, $00, $00, $00, $00, $18, $0E, $00, $00, $00, $00, $00, $38, $00, $00, $00,
    $00);

  SystemFont8x8Ends: array[0..255] of Byte = (
    0, 7, 7, 6, 6, 6, 6, 5, 7, 6, 7, 7, 6, 7, 7, 7, 6, 6, 6, 6, 7, 7, 6, 7, 6, 6, 6, 6, 6, 7, 7, 7, 0, 4, 5, 6, 5, 6,
    6, 2, 4, 4, 7, 5, 3, 5, 3, 6, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 3, 3, 4, 5, 5, 5, 6, 5, 6, 6, 6, 6, 6, 6, 5, 4, 6, 6,
    6, 6, 6, 6, 6, 5, 6, 5, 5, 5, 5, 6, 6, 5, 6, 4, 6, 4, 6, 7, 4, 6, 6, 5, 6, 5, 5, 6, 6, 4, 4, 6, 4, 6, 5, 5, 6, 6,
    5, 5, 5, 6, 5, 6, 6, 5, 5, 5, 4, 5, 6, 6, 5, 6, 5, 7, 6, 6, 6, 6, 7, 5, 5, 5, 6, 4, 5, 5, 5, 7, 6, 5, 5, 5, 6, 6,
    5, 6, 5, 6, 6, 5, 6, 7, 6, 4, 5, 6, 5, 5, 6, 6, 5, 5, 5, 7, 7, 5, 7, 7, 6, 7, 6, 4, 4, 4, 6, 6, 4, 6, 6, 6, 6, 6,
    4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, 7, 7, 7, 3, 7, 7, 6, 5, 6, 6,
    6, 6, 6, 6, 5, 6, 6, 5, 7, 7, 5, 5, 5, 5, 5, 5, 7, 4, 5, 6, 5, 4, 4, 7, 5, 5, 5, 0);

  SystemFont8x8Starts: array[0..255] of Byte = (
    7, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 7, 1, 1, 0, 0, 0,
    0, 0, 1, 1, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0,
    0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
    0, 0, 3, 0, 0, 3, 0, 0, 3, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 2, 3, 3, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 3, 3, 0, 1, 1, 2, 7);

